import React, { Component } from 'react'

// 这是一个公共的父组件,用来定义多个组件中出现的公共的状态和逻辑
export default class Far extends Component {
  state = {
    x: 0,
    y: 0,
  }

  handleMove = (e) => {
    // console.log(e)
    this.setState({
      x: e.clientX,
      y: e.clientY,
    })
  }

  componentDidMount() {
    window.addEventListener('mousemove', this.handleMove)
  }

  componentWillUnmount() {
    window.removeEventListener('mousemove', this.handleMove)
  }
  render() {
    return <this.props.xxx x={this.state.x} y={this.state.y}></this.props.xxx>
  }
}
